//
//  LHretweetCell.swift
//  sinaWeibo
//
//  Created by LiHong on 15/11/1.
//  Copyright © 2015年 LiHong. All rights reserved.
//

import UIKit

class LHRetweetCell: LHStatusesCell {

     override var statuses: LHStatus? {
        didSet {
            let name = statuses?.retweeted_status?.user?.name ?? "没有名称"
            let text = statuses?.retweeted_status?.text ?? "没有内容"
            retweetLabel.text = "@\(name):\(text)"
        }
    }
    
    override func prepareUI() {
        super.prepareUI()
        contentView.insertSubview(bkgButton, belowSubview: pictureView)
        contentView.addSubview(retweetLabel)
        
        // 约束
        // 左上角
        bkgButton.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: contentLabel, size: nil, offset: CGPoint(x: -8, y: 8))
        // 右下角
        bkgButton.ff_AlignVertical(type: ff_AlignType.TopRight, referView: bottomView, size: nil)
        // 转发内容label
        retweetLabel.ff_AlignInner(type: ff_AlignType.TopLeft, referView: bkgButton, size: nil, offset: CGPoint(x: 8, y: 8))
        // 宽度
        contentView.addConstraint(NSLayoutConstraint(item: retweetLabel, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: UIScreen.mainScreen().bounds.width - 2 * 8))
        // 配图视图添加约束
        
        let con = pictureView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: retweetLabel, size: CGSize(width: 0, height: 0), offset: CGPoint(x: 0, y: 8))
        
        pictureViewWidthCon = pictureView.ff_Constraint(con, attribute: NSLayoutAttribute.Width)
        pictureViewHeightCon = pictureView.ff_Constraint(con, attribute: NSLayoutAttribute.Height)
    }
    
    
    
    
    
    //MARK: - 懒加载
    /// 灰色的背景
    private lazy var bkgButton: UIButton = {
        let button = UIButton()
        
        button.backgroundColor = UIColor(white: 0.9, alpha: 1)
        return button
    }()
    
    
    /// 被转发的微博label
    private lazy var retweetLabel: UILabel = {
        let label = UILabel()
        label.textColor = UIColor.darkGrayColor()
        label.numberOfLines = 0
        
        return label
    }()
    
    
}
